﻿@{
    ViewBag.Title = "已办事项";
    Layout = "~/Views/Shared/_Layout_App1.cshtml";
}

@model List<YJ.Data.Model.WorkFlowTask>
<link href="~/Areas/WeiXin/Scripts/weui.min.css" rel="stylesheet" />
<link href="~/Areas/WeiXin/Scripts/ext.css" rel="stylesheet" />
<link href="~/Areas/WeiXin/Scripts/jquery-weui.min.css" rel="stylesheet" />
<link href="~/Scripts/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <style>
        .date {
            color:#999; font-size:12px;
        }
    </style>
    <!-- body 顶部加上如下代码 -->
    <div class="weui-pull-to-refresh__layer">
        <div class='weui-pull-to-refresh__arrow'></div>
        <div class='weui-pull-to-refresh__preloader'></div>
        <div class="down">下拉刷新</div>
        <div class="up">释放刷新</div>
        <div class="refresh">正在刷新</div>
    </div>
    <form id="form1" runat="server">
    <div style="padding: 10px;background-color: #f2f2f2;position:relative;">
        <i class="fa fa-search" style="position:absolute;margin: 7px;font-size: 14px;color:#97989d;"></i>
        <input class="ext-input" id="searchkey" name="searchkey" value="@ViewBag.SearchTitle" placeholder="您共有@(ViewBag.Count)条已办事项" style="width:calc(100% - 71px);border: 1px solid #d6d9e0;border-radius: 3px;padding-left: 24px;"/>
        <input type="submit" class="ext-button" value="&nbsp;&nbsp;查询&nbsp;&nbsp;" style="width: 40px;color: #4e7199;border: none;background: none;box-shadow: none;font-size: 14px;"/>
    </div>
    <div class="" style="overflow-y:auto; overflow-x:hidden;">
        @foreach(var task in Model)
        {
            var address = YJ.Utility.Config.BaseUrl + "/WorkFlowRun/Index_App?flowid=" + task.FlowID
                + "&stepid=" + task.StepID + "&instanceid=" + task.InstanceID + "&taskid=" + task.ID + "&groupid=" + task.GroupID + "&ismobile=1&display=1";
       
        <a class="weui-cell weui-cell_access" href="@address">
            <div class="weui-cell__bd">
                <p>@task.Title<p class="date">完成时间:@(task.CompletedTime1.HasValue ? task.CompletedTime1.Value.ToDateTimeString() : "") 发送人:@task.SenderName</p></p>
            </div>
            <div class="weui-cell__ft">
            </div>
        </a>
        }
    </div>
    <div class="weui-loadmore" id="loaddata">
        <i class="weui-loading"></i>
        <span class="weui-loadmore__tips">正在加载</span>
    </div>
    <div class="weui-loadmore weui-loadmore_line" id="nodata" style="display:none;">
        <span class="weui-loadmore__tips">没有更多数据了</span>
    </div>
    </form>
    <script src="~/Areas/WeiXin/Scripts/jquery-1.11.1.min.js"></script>
    <script src="~/Areas/WeiXin/Scripts/jquery-weui.min.js"></script>
    <script type="text/javascript">
        var pagenumber = 1;
        var loading = false;  //状态标记
        $(function ()
        {
            $(document.body).infinite(50);
            $(document.body).pullToRefresh();
            $(document.body).on("pull-to-refresh", function ()
            {
                //do something
                window.location = window.location;
                $(document.body).pullToRefreshDone();
            });
            $("#loaddata").hide();
            $(document.body).infinite().on("infinite", function ()
            {
                if (loading) return;
                loading = true;
                $("#loaddata").show();
                $.ajax({
                    url: "@YJ.Utility.Config.BaseUrl" + "/WeiXin/CompletedTasks/GetTasks?pagenumber=" + (++pagenumber).toString() + "&pagesize=15&SearchTitle=@ViewBag.SearchTitle", async: false,
                    cache: false, dataType: "json", success: function (json)
                    {
                        if (json.length == 0)
                        {
                            $("#loaddata").hide();
                            $("#nodata").show();
                            $(document.body).destroyInfinite();
                            return;
                        }
                        var html = '';
                        for (var i = 0; i < json.length; i++)
                        {
                            var address = "@YJ.Utility.Config.BaseUrl" + "/WorkFlowRun/Index_App?flowid=" + json[i]["flowid"]
                            + "&stepid=" + json[i]["stepid"] + "&instanceid=" + json[i]["instanceid"] + "&taskid=" + json[i]["id"] + "&groupid=" + json[i]["groupid"] + "&ismobile=1&display=1";
                            html += '<a class="weui-cell weui-cell_access" href="' + address + '">';
                            html += '<div class="weui-cell__bd">';
                            html += '<p>' + json[i]["title"] + '<p class="date">完成时间:' + json[i]["time"] + ' 发送人:' + json[i].sender + '</span></p>';
                            html += '</div>';
                            html += '<div class="weui-cell__ft">';
                            html += '</div>';
                            html += '</a>';
                        }
                        $(".weui-cells").append(html);
                        loading = false;
                        $("#loaddata").hide();
                    }
                });
            });
        });
</script>
